package week6;

import java.text.NumberFormat;

public class Account {
    private final double RATE = 0.035; // interest rate of 3.5%

    private long acctNumber;
    private double balance = 0;
    private String name;

    public String getName() {
        return name;
    }

    public long getAcctNumber() {
        return acctNumber;
    }

    public double getBalance() { return balance; }

    //------------------------------------------------------------
    // Set up the account by defining its owner, account number,
    // and intial balance.
    //------------------------------------------------------------
    public Account(String owner, long account)
    {
        name = owner;
        acctNumber =account;
    }

    //------------------------------------------------------------
    // Deposits the specified amount into the account, Return the
    // new balance.
    //------------------------------------------------------------
    public double deposit(double amount)
    {
        balance = balance + amount;
        return balance;
    }

    //------------------------------------------------------------
    // Withdraws the specified amount from the account and applies
    // the fee. Return the new balance.
    //------------------------------------------------------------
    public double withdraw(double amount, double fee)
    {
        balance = balance - amount - fee;

        return balance;
    }

    //------------------------------------------------------------
    // Adds interest to the account and returns the new balance.
    //------------------------------------------------------------
    public double addInterest()
    {
        balance += (balance * RATE);
        return balance;
    }

    //------------------------------------------------------------
    // Return a one-line description of the account as a string.
    //------------------------------------------------------------

    @Override
    public String toString()
    {
        NumberFormat fmt = NumberFormat.getCurrencyInstance();
        return acctNumber + "\t" + name + "\t" + fmt.format(balance);
    }
}
